package com.js.basic.controller;

import java.util.ArrayList;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.js.basic.domain.dto.ExpertInfoDto;
import org.aspectj.weaver.loadtime.Aj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.js.basic.domain.BsExpertInfo;
import com.js.basic.service.IBsExpertInfoService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 专家信息Controller
 *
 * @author lzq
 * @date 20240703
 */
@RestController
@RequestMapping("/expert")
public class BsExpertInfoController extends BaseController {
    @Autowired
    private IBsExpertInfoService bsExpertInfoService;

    /**
     * 查询专家信息列表
     */
    @RequiresPermissions("expert:expert:list")
    @GetMapping("/list")
    public TableDataInfo list(BsExpertInfo bsExpertInfo) {
        startPage();
        List<BsExpertInfo> list = bsExpertInfoService.selectBsExpertInfoList(bsExpertInfo);
        return getDataTable(list);
    }

    /**
     * 导出专家信息列表
     */
    @RequiresPermissions("expert:expert:export")
    @Log(title = "专家信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BsExpertInfo bsExpertInfo) {
        List<BsExpertInfo> list = bsExpertInfoService.selectBsExpertInfoList(bsExpertInfo);
        ExcelUtil<BsExpertInfo> util = new ExcelUtil<BsExpertInfo>(BsExpertInfo.class);
        util.exportExcel(response, list, "专家信息数据");
    }

    /**
     * 获取专家信息详细信息
     */
    @RequiresPermissions("expert:expert:query")
    @GetMapping(value = "/{expertCode}")
    public AjaxResult getInfo(@PathVariable("expertCode") String expertCode) {
        return success(bsExpertInfoService.selectBsExpertInfoByExpertCode(expertCode));
    }

    /**
     * 新增专家信息
     */
    @RequiresPermissions("expert:expert:add")
    @Log(title = "专家信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BsExpertInfo bsExpertInfo) {
        return toAjax(bsExpertInfoService.insertBsExpertInfo(bsExpertInfo));
    }

    /**
     * 修改专家信息
     */
    @RequiresPermissions("expert:expert:edit")
    @Log(title = "专家信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BsExpertInfo bsExpertInfo) {
        return toAjax(bsExpertInfoService.updateBsExpertInfo(bsExpertInfo));
    }

    /**
     * 删除专家信息
     */
    @RequiresPermissions("expert:expert:remove")
    @Log(title = "专家信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{expertCodes}")
    public AjaxResult remove(@PathVariable String[] expertCodes) {
        return toAjax(bsExpertInfoService.deleteBsExpertInfoByExpertCodes(expertCodes));
    }

    @PostMapping("/getSuccessExpertList")
    public AjaxResult getSuccessExpertList(@RequestBody ExpertInfoDto expertInfoDto) {

        return success(bsExpertInfoService.selectSuccessBsExpertList(expertInfoDto));
    }

    @PostMapping("/getSuccessExpertListAdd")
    public AjaxResult getSuccessExpertListAdd(@RequestBody ExpertInfoDto expertInfoDto) {
        return success(bsExpertInfoService.selectSuccessBsExpertListAdd(expertInfoDto));
    }


}
